<style lang="less" scoped>
.component {
    position: fixed;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    z-index: 8000;
}
.mask {
    position: relative;
    height: 100%;
    background-color: rgba(0, 0, 0, 0);
    display: flex;
    justify-content: center;
    align-items: center;
    transition-duration: 0.3s;
}
.dialog {
    width: 80%;
    background-color: #fff;
    border-radius: 6px;
    opacity: 0;
    .title {
        color: #303030;
        font-size: 0.14rem;
        padding: 0.15rem;
        text-align: center;
        font-weight: 600;
    }
    .msg {
        margin: 0 0.2rem;
        textarea {
            background-color: #f5f6f7;
            width: 100%;
            padding: 0.1rem 0.15rem;
            box-sizing: border-box;
            border: none;
            outline: none;
        }
    }
    .btns {
        justify-content: center;
        align-items: center;
        border-top: 1px solid #eeeeee;
        margin-top: 0.2rem;
        > div {
            flex: 1;
            text-align: center;
            padding: 0.12rem;
            font-size: 0.14rem;
        }
        .cancle {
            color: #888888;
        }
        .submit {
            color: #1b88ee;
            border-left: 1px solid #eeeeee;
        }
    }
}
</style>
<template>
    <div class="component" :style="{'display': display}">
        <div class="mask" :style="{'backgroundColor': bgcolor}">
            <div class="dialog" :style="{'opacity': opacity}">
                <div class="title">驳回</div>
                <div class="msg">
                    <textarea v-model="text" rows="5" placeholder="请输入驳回原因"></textarea>
                </div>
                <div class="btns grid2">
                    <div class="cancle" @click="hide">取消</div>
                    <div class="submit" @click="submit">提交</div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
export default {
    data() {
        return {
            text: "",
            ing: false,
            display: "none",
            bgcolor: "rgba(0,0,0,0)",
            opacity: 0
        };
    },
    props: {
        value: false
    },
    methods: {
        show() {
            if (!this.ing) {
                this.ing = true;
                this.display = "block";
                setTimeout(() => {
                    this.bgcolor = "rgba(0,0,0,0.6)";
                    this.opacity = 1;
                }, 1);
                setTimeout(() => {
                    this.ing = false;
                }, 300);
            }
        },
        hide() {
            if (!this.ing) {
                this.ing = true;
                this.opacity = 0;
                this.bgcolor = "rgba(0,0,0,0)";
                setTimeout(() => {
                    this.display = "none";
                    this.$emit("input", false);
                    this.ing = false;
                }, 300);
            }
        },
        submit() {
            if (!this.text) {
                alert("驳回原因不能为空");
                return false;
            }
            this.$emit("onOk", this.text);
        }
    },
    watch: {
        value: function(val) {
            console.log(val);
            if (val) {
                this.show();
            } else {
                this.hide();
            }
        }
    },
    mounted() {}
};
</script>
